package com.chookss.home.audit.project;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.chookss.MyApp;
import com.chookss.R;
import com.chookss.Urls;
import com.chookss.home.adapter.MyAdapter;
import com.chookss.home.audit.AuditActivity;
import com.chookss.home.audit.shop.ShopAddActivity;
import com.chookss.home.entity.ClockInGroupEntity;
import com.chookss.home.entity.GroupEntity;
import com.chookss.home.entity.WorkNewEntity;
import com.chookss.home.logContacts.ContactsLogChoiceActivity;
import com.chookss.tools.ClearMoreZeroUtil;
import com.chookss.tools.MyEvent;
import com.chookss.tools.MyToast;
import com.chookss.tools.NavigationTools;
import com.chookss.tools.SignUtils2;
import com.chookss.tools.Utils;
import com.chookss.tools.okgoconfig.MyHttpRequest;
import com.chookss.tools.okgoconfig.callback.JsonCallback;
import com.chookss.tools.okgoconfig.callback.ObserverCallback;
import com.chookss.tools.okgoconfig.model.LzyResponse;
import com.chookss.view.BottomListsDialog;
import com.chookss.view.ColorFlipPagerTitleView;
import com.chookss.view.SelectDialogListener;
import com.chookss.view.consecutivescroller.ConsecutiveNoScrollViewPager;
import com.google.gson.reflect.TypeToken;
import com.lvgroup.hospital.base.BaseAct;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.interfaces.OnSelectListener;
import com.lzy.okgo.model.Response;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.RefreshState;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;

import net.lucode.hackware.magicindicator.MagicIndicator;
import net.lucode.hackware.magicindicator.buildins.UIUtil;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

//项目管理
public class ProjectManagementActivity extends BaseAct {
    @BindView(R.id.common_title_txt)
    TextView commonTitleTxt;
    @BindView(R.id.indicator_view)
    MagicIndicator indicatorView;
    @BindView(R.id.viewPager)
    ConsecutiveNoScrollViewPager viewPager;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout smrRf;
    @BindView(R.id.tvGroupMonney)
    TextView tvGroupMonney;
    @BindView(R.id.tvBackMonney)
    TextView tvBackMonney;
    @BindView(R.id.tvDailyReimbursement)
    TextView tvDailyReimbursement;
    @BindView(R.id.tvPeopleCost)
    TextView tvPeopleCost;
    @BindView(R.id.tvGroupMonneyInit)
    TextView tvGroupMonneyInit;
    @BindView(R.id.tvBackMonneyInit)
    TextView tvBackMonneyInit;
    @BindView(R.id.tvDailyReimbursementInit)
    TextView tvDailyReimbursementInit;
    @BindView(R.id.tvPeopleCostInit)
    TextView tvPeopleCostInit;
    @BindView(R.id.tvInit)
    TextView tvInit;
    @BindView(R.id.llData)
    LinearLayout llData;
    @BindView(R.id.tvBottom)
    TextView tvBottom;
    @BindView(R.id.tvBottomInit)
    TextView tvBottomInit;
    @BindView(R.id.tvBottomInit2)
    TextView tvBottomInit2;
    @BindView(R.id.llBottom)
    LinearLayout llBottom;
    @BindView(R.id.ivAudit)
    ImageView ivAudit;
    @BindView(R.id.common_title_txt_iv)
    ImageView common_title_txt_iv;
    @BindView(R.id.llNone)
    LinearLayout llNone;
    @BindView(R.id.common_right_more_ll)
    LinearLayout common_right_more_ll;
    @BindView(R.id.common_right_iv_ll)
    RelativeLayout common_right_iv_ll;
    private ArrayList<Fragment> fragments = new ArrayList<>();
    private GroupRoleFragment groupRoleFragment = null;
    private GroupCostFragment groupCostFragment = null;
    private GroupShopFragment groupShopFragment = null;
    private List<String> titleList = new ArrayList<>();
    private MyAdapter pagerAdapter;
    private String[] groupArray = null;
    private List<ClockInGroupEntity> groupEntities = new ArrayList<>();
    private String groupCode = "", groupName = "";
    private String mainCd = "";//是否有主项目组
    private int index = 0;//分类下标
    private BottomListsDialog bottomListsDialog = null;
    private List<String> dialogList = new ArrayList<>();
    private GroupEntity groupEntity;
    private static int SOURSE = 11;//选员工所用标识
    private boolean isDetailData=false;//详情是否获取到值
    private boolean isSjAmt=false;//项目开支金额是否获取到值
    private String baoxiaoAmt="";//项目开支的金额  单独金额

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        setContentView(R.layout.activity_project_management);
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        initState();
        NavigationTools.saveUseRecord(this, "1", "40");
        commonTitleTxt.setText("项目名称");
        viewPager.setNoScroll(true);
        dialogList.add("项目预算");
        dialogList.add("添加员工");
        dialogList.add("添加物料");
        dialogList.add("取消");
        groupRoleFragment = new GroupRoleFragment();
        groupCostFragment = new GroupCostFragment();
        groupShopFragment = new GroupShopFragment();
        fragments.add(groupRoleFragment);
        fragments.add(groupCostFragment);
        fragments.add(groupShopFragment);
        titleList.add("项目成员");
        titleList.add("人力服务");
        titleList.add("项目物料");
        CommonNavigator commonNavigator = new CommonNavigator(this);
        commonNavigator.setScrollPivotX(0.65f);
        commonNavigator.setAdjustMode(true);
        commonNavigator.setAdapter(new CommonNavigatorAdapter() {
            @Override
            public int getCount() {
                return titleList == null ? 0 : titleList.size();
            }

            @Override
            public IPagerTitleView getTitleView(Context context, int title_index) {
                SimplePagerTitleView simplePagerTitleView = new ColorFlipPagerTitleView(context);
                simplePagerTitleView.setIncludeFontPadding(false);
                simplePagerTitleView.setText(titleList.get(title_index));
                simplePagerTitleView.setTextSize(16);
                simplePagerTitleView.setPadding(Utils.dip2px(ProjectManagementActivity.this, 15), 0, Utils.dip2px(ProjectManagementActivity.this, 15), 0);
                simplePagerTitleView.setNormalColor(Color.rgb(129, 129, 129));
                simplePagerTitleView.setSelectedColor(Color.rgb(225, 36, 22));
                simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (pagerAdapter == null) {
                            index = title_index;
                            indicatorView.onPageSelected(title_index);
                            indicatorView.getNavigator().notifyDataSetChanged();
                        } else {
                            viewPager.setCurrentItem(title_index);
                        }

                    }
                });
                return simplePagerTitleView;
            }

            @Override
            public IPagerIndicator getIndicator(Context context) {
                LinePagerIndicator indicator = new LinePagerIndicator(context);
                indicator.setMode(LinePagerIndicator.MODE_MATCH_EDGE);
                indicator.setLineHeight(UIUtil.dip2px(context, 2));
//                indicator.setLineWidth(UIUtil.dip2px(context, 42));
                indicator.setRoundRadius(UIUtil.dip2px(context, 1));
                indicator.setStartInterpolator(new AccelerateInterpolator());
                indicator.setEndInterpolator(new DecelerateInterpolator(2.0f));
                indicator.setColors(Color.rgb(225, 36, 22));
                return indicator;
            }
        });
        indicatorView.setNavigator(commonNavigator);
        indicatorView.onPageSelected(index);
        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                indicatorView.onPageScrolled(position, positionOffset, positionOffsetPixels);
            }

            @Override
            public void onPageSelected(int position) {
                indicatorView.onPageSelected(position);
                index = position;
                changeBottomUi();
            }

            @Override
            public void onPageScrollStateChanged(int state) {
                indicatorView.onPageScrollStateChanged(state);
            }
        });
        pagerAdapter = new MyAdapter(getSupportFragmentManager(), fragments);
        viewPager.setAdapter(pagerAdapter);
        viewPager.setOffscreenPageLimit(2);
        viewPager.setCurrentItem(index);
        smrRf.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout r) {
                // 把加载的动作传给当初的fragment
                if (viewPager == null) {
                    return;
                }
                refreshLoad(false);

            }

            @Override
            public void onRefresh(@NonNull RefreshLayout r) {
                if (viewPager == null) {
                    return;
                }
                refreshLoad(true);
            }
        });
        indicatorView.post(new Runnable() {
            @Override
            public void run() {
                if (viewPager == null) {
                    return;
                }
                viewPager.setAdjustHeight(indicatorView.getHeight());
            }
        });
        showLoading();
        getGroupList();
        getworkList();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        getworkList();
    }

    private void getworkList() {
        Map<String, String> map = new HashMap<>();
        //待审核 传0 已审核不传
        map.put("auditStatus", "0");
        map.put("pageNum", "1");
        map.put("pageSize", "1");
        // 1-新闻 2-视频 3-补卡 4-请假 5-外勤 6-图文7报销8物品9借款10补贴
        map.put("type", "16,17");
        MyHttpRequest.getDefault().getRequest(new TypeToken<LzyResponse<List<WorkNewEntity>>>() {
        }.getType(), null, Urls.selectKqMyWorkList, SignUtils2.makeSignStr(map), false, new ObserverCallback<List<WorkNewEntity>>() {
            @Override
            public void onSuccess(List<WorkNewEntity> data) {
                if (ivAudit == null) {
                    return;
                }
                if (data != null && data.size() > 0) {
                    ivAudit.setVisibility(View.VISIBLE);
                } else {
                    ivAudit.setVisibility(View.GONE);
                }
            }

            @Override
            public void onError(String errorMsg) {
                if (ivAudit != null) {
                    ivAudit.setVisibility(View.GONE);
                }
            }
        });
    }

    private void firstRefresh() {
        if (!Utils.isNull(groupCode)) {
            groupRoleFragment.setGroupCode(groupCode, groupName);
            groupCostFragment.setGroupCode(groupCode, groupName);
            groupShopFragment.setGroupCode(groupCode, groupName);
        }
        smrRf.autoRefresh();
        if (viewPager.getCurrentItem() == 0) {
            groupCostFragment.onRefresh(smrRf);
            groupShopFragment.onRefresh(smrRf);
        } else if (viewPager.getCurrentItem() == 1) {
            groupRoleFragment.onRefresh(smrRf);
            groupShopFragment.onRefresh(smrRf);
        } else if (viewPager.getCurrentItem() == 2) {
            groupRoleFragment.onRefresh(smrRf);
            groupCostFragment.onRefresh(smrRf);
        }
        getGroupDetail();
    }

    private void refreshLoad(boolean isRefresh) {
        if (viewPager.getCurrentItem() == 0) {
            if (isRefresh) {
                groupRoleFragment.onRefresh(smrRf);
            } else {
                groupRoleFragment.onLoadMore(smrRf);
            }
        } else if (viewPager.getCurrentItem() == 1) {
            if (isRefresh) {
                groupCostFragment.onRefresh(smrRf);
            } else {
                groupCostFragment.onLoadMore(smrRf);
            }
        } else if (viewPager.getCurrentItem() == 2) {
            if (isRefresh) {
                groupShopFragment.onRefresh(smrRf);
            } else {
                groupShopFragment.onLoadMore(smrRf);
            }
        }
    }

    private void getGroupList() {
        //项目组基本数据
        MyHttpRequest.getDefault().getRequest(new TypeToken<LzyResponse<List<ClockInGroupEntity>>>() {
        }.getType(), null, Urls.selectMyChargeItemGroupList, SignUtils2.makeSignStr(null), false, new ObserverCallback<List<ClockInGroupEntity>>() {
            @Override
            public void onSuccess(List<ClockInGroupEntity> data) {
                groupEntities.clear();
                groupCode = "";
                if (data != null && data.size() > 0) {
                    if (commonTitleTxt == null) {
                        return;
                    }

                    groupEntities.addAll(data);
                    groupArray = new String[groupEntities.size()];
                    for (int i = 0; i < groupEntities.size(); i++) {
                        if ("1".equals(groupEntities.get(i).getMainCd())) {
                            mainCd = groupEntities.get(i).getMainCd();
                            groupArray[i] = groupEntities.get(i).getGroupName() + "[常驻]";
                            groupCode = groupEntities.get(i).getGroupCode();
                            groupName = groupEntities.get(i).getGroupName();
                            commonTitleTxt.setText(groupEntities.get(i).getGroupName());
                        } else {
                            groupArray[i] = groupEntities.get(i).getGroupName();
                        }
                        if (i == groupEntities.size() - 1) {
                            if (Utils.isNull(mainCd)) {
                                groupCode = groupEntities.get(0).getGroupCode();
                                groupName = groupEntities.get(0).getGroupName();
                                commonTitleTxt.setText(groupEntities.get(0).getGroupName());
                            }
                            firstRefresh();
                        }
                    }

                } else {
                    common_title_txt_iv.setVisibility(View.GONE);
                    smrRf.setVisibility(View.GONE);
                    llBottom.setVisibility(View.GONE);
                    common_right_more_ll.setVisibility(View.GONE);
                    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)common_right_iv_ll.getLayoutParams();
                    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                    common_right_iv_ll.setLayoutParams(params);
                    llNone.setVisibility(View.VISIBLE);
                    commonTitleTxt.setText("项目管理");
                    dismissLoading();
                }

            }

            @Override
            public void onError(String errorMsg) {
                dismissLoading();
                MyToast.show(Utils.onErrorTips(errorMsg));
            }
        });
    }

    private void getGroupDetail() {
        //项目组信息
        isDetailData=false;
        isSjAmt=false;
        baoxiaoAmt="0";
        getSjAmt();
        Map<String, String> map = new HashMap<>();
        map.put("groupCode", groupCode);
        MyHttpRequest.getDefault().getRequest(new TypeToken<LzyResponse<GroupEntity>>() {
        }.getType(), null, Urls.selectItemGroupDetailByGroupCode, SignUtils2.makeSignStr(map), false, new ObserverCallback<GroupEntity>() {
            @Override
            public void onSuccess(GroupEntity data) {
                dismissLoading();
                if (data == null) {
                    MyToast.show("数据异常");
                    return;
                }
                groupEntity = data;
                isDetailData=true;
                if(isDetailData&&isSjAmt){
                    //表面另外一半数据好了
                    dealAmt(data,baoxiaoAmt);
                }

            }

            @Override
            public void onError(String errorMsg) {
                dismissLoading();
                MyToast.show(Utils.onErrorTips(errorMsg));
            }
        });
    }
    private void getSjAmt() {
        //项目组信息
        Map<String, String> map = new HashMap<>();
        map.put("groupCode", groupCode);
        MyHttpRequest.getRequest(Urls.getSjAmt, this, SignUtils2.makeSignStr(map), new JsonCallback<String>() {
            @Override
            public void onSuccess(Response<String> response) {
                dismissLoading();
                try {
                    JSONObject jsonObject = new JSONObject(response.body().toString());
                    if ("200".equals(jsonObject.getString("code"))) {
                         isSjAmt=true;
                         baoxiaoAmt=jsonObject.getString("data");
                        if(isDetailData&&isSjAmt){
                            //表面另外一半数据好了
                            dealAmt(groupEntity,baoxiaoAmt);
                        }
                    } else {

                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });

    }
    private void dealAmt(GroupEntity data,String baoxiaoAmt){
        String sjAmtTotal=ClearMoreZeroUtil.subZeroAndDot(data.getSjAmtTotal());
        String returnAmt=ClearMoreZeroUtil.subZeroAndDot(data.getReturnAmt());
        String sjAmtBaoxiao=ClearMoreZeroUtil.subZeroAndDot(baoxiaoAmt);
        String sjAmtEmp=ClearMoreZeroUtil.subZeroAndDot(data.getSjAmtEmp());
        tvGroupMonney.setText(Utils.changeW(sjAmtTotal));
        tvBackMonney.setText(Utils.changeW(returnAmt));
        tvDailyReimbursement.setText(Utils.changeW(sjAmtBaoxiao));
        tvPeopleCost.setText(Utils.changeW(sjAmtEmp));
        String init = "";
        if (Float.parseFloat(sjAmtTotal) >= 10000) {
            tvGroupMonneyInit.setText("项目金额(万元)");
        } else {
            tvGroupMonneyInit.setText("项目金额(元)");
        }

        if (Float.parseFloat(returnAmt) >= 10000) {
            tvBackMonneyInit.setText("回款金额(万元)");
        } else {
            tvBackMonneyInit.setText("回款金额(元)");
        }
        if (Float.parseFloat(sjAmtBaoxiao) >= 10000) {
            tvDailyReimbursementInit.setText("项目开支(万元)");
        } else {
            tvDailyReimbursementInit.setText("项目开支(元)");
        }
        if (Float.parseFloat(sjAmtEmp) >= 10000) {
            tvPeopleCostInit.setText("人力成本(万元)");
        } else {
            tvPeopleCostInit.setText("人力成本(元)");
        }
        if (Float.parseFloat(sjAmtTotal) > Float.parseFloat(ClearMoreZeroUtil.subZeroAndDot(data.getYsAmtTotal()))) {
            tvGroupMonney.setTextColor(getResources().getColor(R.color.main_color));
            init = "项目金额";
        } else {
            tvGroupMonney.setTextColor(getResources().getColor(R.color.black));
        }
        if (Float.parseFloat(sjAmtBaoxiao) > Float.parseFloat(ClearMoreZeroUtil.subZeroAndDot(data.getYsAmtBaoxiao()))) {
            tvDailyReimbursement.setTextColor(getResources().getColor(R.color.main_color));
            if (Utils.isNull(init)) {
                init = "项目开支";
            } else {
                init = init + "、项目开支";
            }
        } else {
            tvDailyReimbursement.setTextColor(getResources().getColor(R.color.black));
        }
//                if (Float.parseFloat(sjAmtEmp) > Float.parseFloat(ClearMoreZeroUtil.subZeroAndDot(data.getYsAmtEmp()))) {
//                    tvPeopleCost.setTextColor(getResources().getColor(R.color.main_color));
//                    if(Utils.isNull(init)){
//                        init="人力成本";
//                    }else{
//                        init=init+"、人力成本";
//                    }
//                } else {
//                    tvPeopleCost.setTextColor(getResources().getColor(R.color.black));
//                }
        if (Float.parseFloat(ClearMoreZeroUtil.subZeroAndDot(data.getSjAmtEmpDaka())) > Float.parseFloat(ClearMoreZeroUtil.subZeroAndDot(data.getYsAmtEmpDaka()))) {
            if (Utils.isNull(init)) {
                init = "人力服务";
            } else {
                init = init + "、人力服务";
            }
        }
        if (Float.parseFloat(ClearMoreZeroUtil.subZeroAndDot(data.getGoodsNum())) > Float.parseFloat(ClearMoreZeroUtil.subZeroAndDot(data.getYsGoodsNum()))) {
            if (Utils.isNull(init)) {
                init = "物料";
            } else {
                init = init + "、物料";
            }
        }
        if (Utils.isNull(init)) {
            tvInit.setVisibility(View.GONE);
        } else {
            tvInit.setText(init + "超出预算");
            tvInit.setVisibility(View.VISIBLE);
        }
    }

    private void changeBottomUi() {
        if (index == 0) {
            if (groupRoleFragment != null) {
                if("0".equals(ClearMoreZeroUtil.subZeroAndDot(groupEntity.getEmployeeNums()))){
                    llBottom.setVisibility(View.GONE);
                }else{
                    tvBottom.setText(ClearMoreZeroUtil.subZeroAndDot(groupEntity.getEmployeeNums()));
                    tvBottomInit.setText("总人数");
                    tvBottomInit2.setText("人");
                    llBottom.setVisibility(View.VISIBLE);
                }

            }
        } else if (index == 1) {
            if (groupCostFragment != null) {
                if("0".equals(ClearMoreZeroUtil.subZeroAndDot(groupEntity.getSjAmtEmpDaka()))){
                    llBottom.setVisibility(View.GONE);
                }else{
                    tvBottom.setText(ClearMoreZeroUtil.subZeroAndDot(groupEntity.getSjAmtEmpDaka()));
                    tvBottomInit.setText("累计打卡");
                    tvBottomInit2.setText("人/天");
                    llBottom.setVisibility(View.VISIBLE);
                }
            }
        } else {
            llBottom.setVisibility(View.GONE);
        }
    }

    private void loadEnd() {
        if (null != smrRf && smrRf.getState() == RefreshState.Refreshing)
            smrRf.finishRefresh(true);
        if (null != smrRf && smrRf.getState() == RefreshState.Loading)
            smrRf.finishLoadMore(true);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMoonEvent(MyEvent messageEvent) {
        //事件订阅者处理事件
        if (messageEvent.getMap() != null) {
            Map<String, String> map = messageEvent.getMap();
        } else {
            String msg = messageEvent.getMessage();
            if (Utils.isNull(msg)) {
                return;
            }
            if (msg.equals("RefreshGroupRecord")) {
                getGroupDetail();
            } else if (msg.equals("RefreshGroupRoleNum")) {
                if (groupEntity == null) {
                    return;
                }
                changeBottomUi();
            }
        }
    }

    @OnClick({R.id.common_title_back, R.id.topLl, R.id.llGroupMonney, R.id.llBackMonney, R.id.llDailyReimbursement, R.id.llPeopleCost, R.id.common_right_iv_ll, R.id.common_right_more_ll})
    public void onClick(View view) {
        Intent intent = null;
        switch (view.getId()) {
            case R.id.common_title_back:
                finish();
                break;
            case R.id.topLl:
                if (groupArray == null) {
                    MyToast.show("无可选项目组，请联系管理员配置");
                    return;
                }
                new XPopup.Builder(ProjectManagementActivity.this)
                        .maxWidth(Utils.dip2px(ProjectManagementActivity.this, 260))
                        .maxHeight(Utils.dip2px(ProjectManagementActivity.this, 300))
                        .asCenterList("请选择项目组", groupArray,
                                new OnSelectListener() {
                                    @Override
                                    public void onSelect(int position, String text) {
                                        groupCode = groupEntities.get(position).getGroupCode();
                                        groupName = groupEntities.get(position).getGroupName();
                                        commonTitleTxt.setText(text.replace("[常驻]", ""));
                                        firstRefresh();
                                    }
                                })
                        .show();
                break;
            case R.id.common_right_iv_ll:
                //项目管理审批
                intent = new Intent(this, AuditActivity.class);
                intent.putExtra("type", 16);
                startActivity(intent);
                break;
            case R.id.llGroupMonney:
                //项目金额
                intent = new Intent(this, GroupMoneyActivity.class);
                intent.putExtra("type", 0);
                intent.putExtra("groupEntity", groupEntity);
                startActivity(intent);
                break;
            case R.id.llBackMonney:
                //回款金额
                intent = new Intent(this, GroupMoneyActivity.class);
                intent.putExtra("type", 1);
                intent.putExtra("groupEntity", groupEntity);
                startActivity(intent);
                break;
            case R.id.llDailyReimbursement:
                //项目开支
                intent = new Intent(this, GroupReimbursementActivity.class);
                intent.putExtra("type", 0);
                intent.putExtra("groupData", baoxiaoAmt);
                intent.putExtra("groupCode", groupCode);
                startActivity(intent);
                break;
            case R.id.llPeopleCost:
                //人力成本
                intent = new Intent(this, GroupReimbursementActivity.class);
                intent.putExtra("type", 1);
                intent.putExtra("groupData", groupEntity.getSjAmtEmp());
                intent.putExtra("groupCode", groupCode);
                startActivity(intent);
                break;
            case R.id.common_right_more_ll:
                bottomListsDialog = new BottomListsDialog(this, dialogList, new SelectDialogListener() {
                    @Override
                    public void onCancel() {
                    }

                    @Override
                    public void onListItemClick(int position, List<String> list) {
                        if (position == 0) {
                            Intent intent = new Intent(ProjectManagementActivity.this, GroupBudgetActivity.class);
                            intent.putExtra("groupEntity", groupEntity);
                            startActivity(intent);
                        } else if (position == 1) {
                            if (groupRoleFragment == null) {
                                return;
                            }
                            MyApp.contactEntityLogList.clear();
                            MyApp.contactEntityLogList.addAll(groupRoleFragment.getList());
                            Intent intent = new Intent(ProjectManagementActivity.this, ContactsLogChoiceActivity.class);
                            intent.putExtra("source", SOURSE + "");
                            intent.putExtra("oldContactNum", groupRoleFragment.getList().size());
                            intent.putExtra("hrName", "已选择项目组成员：");
                            startActivity(intent);
                        } else if (position == 2) {
                            Intent intent = new Intent(ProjectManagementActivity.this, ShopAddActivity.class);
                            intent.putExtra("isProjectManager", true);
                            intent.putExtra("groupCode", groupCode);
                            intent.putExtra("groupName", groupName);
                            startActivity(intent);
                        }
                        bottomListsDialog.dismiss();
                    }
                });
                bottomListsDialog.show();
                break;
        }
    }
}
